<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
if(!function_exists('array_column')){
   function array_column($array,$columnKey,$indexKey=null){
       $result = [];
       foreach ($array as $row) {
           $key    = $value    = null;
           $keySet = $valueSet = false;

           if (null !== $indexKey && array_key_exists($indexKey, $row)) {
               $key    = (string) $row[$indexKey];
               $keySet = true;
           }

           if (null === $columnKey) {
               $valueSet = true;
               $value    = $row;
           } elseif (is_array($row) && array_key_exists($columnKey, $row)) {
               $valueSet = true;
               $value    = $row[$columnKey];
           }

           if ($valueSet) {
               if ($keySet) {
                   $result[$key] = $value;
               } else {
                   $result[] = $value;
               }
           }
       }

       return $result;
   }
}